<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" import="org.apache.commons.lang.StringEscapeUtils"%>
<%@ include file="/WEB-INF/taglibs.jsp"%>
<script>
$(function(){
		$("#serveMenu").addClass("cur");
	});
</script>	

<div class="conTit fixed">
    <p>
   		<c:choose>
			<c:when test="${serveType.id ==null}">新增服务类型</c:when>
			<c:otherwise>修改服务类型</c:otherwise>
		</c:choose>
		<div class="fr"><a href="javascript:void(0);" class="backBtn" onclick="window.history.back(-1);">返回</a></div>
    </p>
</div>

<div style="margin-left: 10px;">
  <form id="carrierForm" action="" method="post" enctype="multipart/form-data">
	<div class="inputArea">
	     <label>服务类型:<font style="color: red">*</font></label>
	     <div class="inputLine">
	          <input type="text" id="typeName" name="typeName" value="${serveType.typeName}" maxlength="16"/>
	     </div>
	</div>
	<div class="inputArea">
		<label>服务类型种类:<font style="color: red">*</font></label>
		<input type="radio" name="category" <c:if test="${serveType.category == 1}">checked=true</c:if> value="1"/> 房屋
		<input type="radio" name="category" <c:if test="${serveType.category == 2}">checked=true</c:if> value="2"/> 其他 
	</div>			
	<div class="inputArea">
		<label>服务标签背景色:<font style="color: red">*</font></label>
		<select id="typeColor">
			<option <c:if test="${serveType.typeColor == 1}">selected=selected</c:if> value="1">黄色</option>
			<option <c:if test="${serveType.typeColor == 2}">selected=selected</c:if> value="2">红色</option>
			<option <c:if test="${serveType.typeColor == 3}">selected=selected</c:if> value="3">绿色</option>
		</select>
	</div>	
	<div class="save">
	     <a href="javascript:void(0);" class="backBtn" onclick="saveCarrier()">保存</a>
	</div>
    <input type="hidden" name="id" id="caseId" value="${serveType.id}" />
  </form>
</div>
		
<script type="text/javascript">
	function saveCarrier() {
		var typeName = $("#typeName").val();
		var category = $("input[name='category']").val();
		var typeColor = $("#typeColor option:selected").val();
		
		if($.trim(typeName) == "") {
			layer.alert("请输入类型名称");
			return;
		}
		if($.trim(category) == ''){
			layer.alert("请输入种类");
			return;
		}		
		if($.trim(typeColor) == ''){
			layer.alert("请选择标签颜色");
			return;
		}
		$.ajax({
			url:"${ctx}/admin/serveInfo/saveServeType.json",
			data:{'id':'${serveType.id}','typeName':$("#typeName").val(),'category':$("input[name='category']").val(),'typeColor':typeColor},
			success:function(result){
	        	result = eval("("+result+")");
	    		if(result.status == "true" || result.status == true){
	    			alert(result.msg);
	    			window.location.href = "${ctx}/admin/serveInfo/serveTypeList.htm";
	    		}else{
	    			alert(result.msg);
	    		}	    		
	    	}
		})
	}
</script>